package LeetCode.month01.day28;

public class No704 {
    public static void main(String[] args) {
        System.out.println(search(new int[]{-1,0,3,5,9,12},9));
    }
    public static int search(int[] nums, int target) {
        int n = nums.length;
        int left = 0,right = n-1;
        while(left<right){
            int mid = left+(right-left)/2;
            if(nums[mid]==target) {
                return mid;
            }
            if(nums[mid]>target){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }
        return -1;
    }
}
